<?php  
	session_start();       
	/**    
	*@package admin        
	*@desc Views the report made by a user.        
	*/           
	if ($_SESSION["role"] != "admin")      
		{              
		header('Location: ../index.php');              
		exit();        
		}            
		if(!isset($_GET['id']))      
	
		die("Do not directtly call this page");  
	
	/**    
	*@desc This include file will load the directory settings for the Smarty Templates     
	*/     
	require '../includes/smarty.inc';     
	$smarty->assign('title', "View Report");       
	$smarty->assign('user_id', $_SESSION["user_id"]);              
	$smarty->assign('last', $_SESSION["lastviewed"]);      
	$smarty->assign('firstname', $_SESSION["firstname"]);  
	$smarty->assign('role', $_SESSION["role"]);    
	$smarty->assign('top5', $_SESSION["top5"]);            
	$smarty->assign('pathdepth', "../");   
	$smarty->display('header.tpl');         
	
	$id = $_GET['id'];            //get reports from database    
	
	$query = "SELECT r.report_id as id, r.forwarded as forwarded, r.report as report, u.email as email, p.name as park, p.address as address, s.name as suburb, c.email as council FROM reports r, users u, suburbs s, parks p, councils c WHERE (r.report_id = $id) AND (r.user_id = u.user_id) AND (r.park_id = p.park_id) AND (p.suburb_id = s.suburb_id) AND (s.council_id = c.council_id)";          
	
	/**    
	*@desc This include file connects to the database.     
	*/     
	require '../includes/connect.inc';            
	
	//run query    
	$result = mysql_query($query, $connection) or die(mysql_error());             
	
	//disconnect from db   
	mysql_close($connection);             
	
		$row = mysql_fetch_array($result);     
		$id = $row['id'];      
		$user = $row['email'];         
		$report = $row['report'];      
		$park = $row['park'];  
		$address = $row['address'];    
		$suburb = $row['suburb'];      
		$council = $row['council'];    
		$forwarded = $row['forwarded'];      
		
		$smarty->assign('id', $id);    
		$smarty->assign('user', $user);        
		$smarty->assign('report', $report);    
		$smarty->assign('park', $park);        
		$smarty->assign('address', $address);  
		$smarty->assign('suburb', $suburb);    
		$smarty->assign('forwarded', $forwarded);      
		$smarty->assign('council', $council);  
		$smarty->assign('admin', $_SESSION['email']);   
		
		$smarty->display('admin/report.tpl');         
		
		//Footer       
		$smarty->assign('pathdepth', "../");   
		$smarty->display('footer.tpl');                
	
?>
